package com.taotao.rest.web;

import com.taotao.common.JsonUtils;
import com.taotao.pojo.TbContent;
import com.taotao.rest.service.TbContentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("/content")
public class TbContentController {

    @Autowired
    private TbContentService tbContentService;

    /**
     * 根据类别id（categoryId）查询前端页面轮播图
     * @param categoryId
     * @return
     */
    @RequestMapping("/all/{cat_id}")
    @ResponseBody
    public String get(@PathVariable("cat_id") Long categoryId){
        List<TbContent> tbContentList = tbContentService.getAllContent(categoryId);
        String result = JsonUtils.objectToJson(tbContentList);
        return result;
    }
}
